package algos;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ContextStack<T> {
	public List<T> contextsStack;
	public List<Iterator<Action<T>>> actionsStack;
	
	public ContextStack(T context_t, Iterator<Action<T>> actions_t) {
		contextsStack = new ArrayList<T>();
		contextsStack.add(0, context_t);
		actionsStack = new ArrayList<Iterator<Action<T>>>();
		actionsStack.add(0, actions_t);
	}
	
	public T currentContext() {
		return contextsStack.isEmpty() ? null : contextsStack.get(0);
	}
	
	public Iterator<Action<T>> currentActionsIterator() {
		return actionsStack.get(0);
	}
	
	public void push(T context_t, Iterator<Action<T>> actions_t) {
		contextsStack.add(0, context_t);
		actionsStack.add(0, actions_t);
	}
	
	public void pop() {
		contextsStack.remove(0);
		actionsStack.remove(0);
	}
	
	public String toString()
	{
		return contextsStack.toString();
	}
}
